package mil.af.amc.adpetracker.service;

import mil.af.amc.adpetracker.dao.EquipmentTypeDao;
import mil.af.amc.adpetracker.dao.ManufacturerDao;
import mil.af.amc.adpetracker.model.EquipmentType;
import mil.af.amc.adpetracker.model.Manufacturer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

/**
 * Please Fill in this Javadoc
 *
 * @author TSgt Jason Ferguson
 */
@Service("manufacturerService")
public class ManufacturerServiceImpl implements ManufacturerService{

    private ManufacturerDao manufacturerDao;

    @Autowired
    public void setManufacturerDao(ManufacturerDao manufacturerDao) {
        this.manufacturerDao = manufacturerDao;
    }

    private EquipmentTypeDao equipmentTypeDao;

    @Autowired
    public void setEquipmentTypeDao(EquipmentTypeDao equipmentTypeDao) {
        this.equipmentTypeDao = equipmentTypeDao;
    }

    public void createManufacturer(Map manuMap) {

        Manufacturer manu = new Manufacturer();
        manu.setName((String) manuMap.get("name"));

        manufacturerDao.saveOrUpdate(manu);

    }

    public List<Manufacturer> getAll() {

        return manufacturerDao.getAll();

    }

    public Manufacturer getById(int id) {

        return manufacturerDao.getById(id);

    }

    public List<Manufacturer> getManufacturerByEquipmentType(int equipmentTypeId) {

        EquipmentType type = equipmentTypeDao.getById(equipmentTypeId);

        return manufacturerDao.getManufacturerByEquipmentType(type);
        
    }


}
